/**
 * Created by Administrator on 2017/7/20.
 */
(function() {
    "use strict";
    var app = angular.module("angularApp");
    app.controller('expertOrderCtrl', function ($scope,$rootScope, $http,$uibModal,fac) {
        $scope.search = {};
        $scope.pageModel = {};

            $rootScope.expertTypeDict = [
            ['0','线上专家一对一志愿辅导(1988.00 元,两个小时)'],
            ['1','线上资深专家一对一志愿辅导(2988.00 元,两个小时)'],
            ['2','线下专家一对一志愿辅导(3888.00 元,两个小时)'],
            ['3','线下资深专家一对一志愿辅导(5888.00 元,两个小时)'],
            ['4','资深专家线上生涯规划指导(1588.00  元)'],
            ['5','资深专家线下生涯规划指导(1988.00  元)'],
            ['6','三位一体咨询(300.00  元)'],
            ['7','留学咨询(300.00  元)'],
            ['8','选考咨询(300.00  元)'],
            ['9','资深专家高考资源审核(500.00  元)']]


        $scope.find = function(pageNo){
            $.extend($scope.search,{currentPage:pageNo||$scope.pageModel.currentPage||1,pageSize:$scope.pageModel.pageSize||10});
            fac.getPageResult("../expertOrder/list",$scope.search,function(data){
                $scope.pageModel = data;
            });
        };
        $scope.find();

        //添加与保存instance
        $scope.deal = function(item){
            var copy = angular.extend({},item);
            var modal = $uibModal.open({
                animation: false,
                size:'',
                templateUrl: 'view/school/expertOrder.modal.html',
                controller: 'expertOrderModalCtrl'
                ,resolve: {item: copy}
            });
            modal.result.then(function () {
                $scope.find();
            }, function () {
                console.info('Modal dismissed at: ' + new Date());
            });
        };

    });

    app.controller('expertOrderModalCtrl', function($scope,$rootScope,$http,$uibModalInstance,$q,fac,item) {
        $scope.dealStatusDict = [[true,"已处理"],[false,"未处理"]]

        $scope.item = item;

        $scope.save = function (form) {
            form.$setSubmitted(true);
            if (!form.$valid) {
                return;
            }
            $http.post("../expertOrder/dealOrder", item).success(function (resp, status, headers, config) {
                if (resp.code === 0) {
                    $uibModalInstance.close();
                } else {
                    alert(resp.msg);
                }
            })
        }
    });


})();